package c.h.a.j0;

import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.os.Bundle;
import android.util.Size;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.e;
import androidx.recyclerview.widget.RecyclerView.z;
import c.h.a.d0.b;
import c.h.a.m0.i;
import c.h.a.m0.k;
import c.h.a.n0.g;
import com.liuzh.deviceinfo.DeviceInfoApp;
import com.liuzh.deviceinfo.view.togglebuttongroup.SingleSelectToggleGroup;
import java.util.ArrayList;

/* compiled from: TabCamera */
public class l0 extends h0 {
    public static final /* synthetic */ int d0 = 0;
    public ViewGroup W;
    public SingleSelectToggleGroup X;
    public RecyclerView Y;
    public a Z;
    public ArrayList<b> b0 = new ArrayList();
    public CameraManager c0;

    /* compiled from: TabCamera */
    public class a extends e<a> {

        /* compiled from: TabCamera */
        public class a extends z {
            public TextView t;
            public TextView u;

            public a(a aVar, View view) {
                super(view);
                this.t = (TextView) view.findViewById(2131296753);
                this.u = (TextView) view.findViewById(2131297325);
            }
        }

        public int a() {
            return l0.this.b0.size();
        }

        public void f(z zVar, int i) {
            a aVar = (a) zVar;
            b bVar = (b) l0.this.b0.get(i);
            aVar.t.setText(bVar.a);
            aVar.u.setText(bVar.b);
        }

        public z g(ViewGroup viewGroup, int i) {
            return new a(this, LayoutInflater.from(l0.this.k()).inflate(2131492984, viewGroup, false));
        }
    }

    public View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        ViewGroup viewGroup2;
        if (this.W == null) {
            int i;
            int id;
            viewGroup2 = (ViewGroup) layoutInflater.inflate(2131493050, viewGroup, false);
            this.W = viewGroup2;
            this.X = (SingleSelectToggleGroup) viewGroup2.findViewById(2131296419);
            this.Y = (RecyclerView) this.W.findViewById(2131296829);
            CameraManager cameraManager = (CameraManager) Z().getSystemService("camera");
            this.c0 = cameraManager;
            if (cameraManager != null) {
                try {
                    for (String str : cameraManager.getCameraIdList()) {
                        try {
                            CameraCharacteristics cameraCharacteristics = this.c0.getCameraCharacteristics(str);
                            StreamConfigurationMap streamConfigurationMap = (StreamConfigurationMap) cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                            if (streamConfigurationMap != null) {
                                String x;
                                Size[] outputSizes = streamConfigurationMap.getOutputSizes(256);
                                Integer num = (Integer) cameraCharacteristics.get(CameraCharacteristics.LENS_FACING);
                                if (num != null) {
                                    int intValue = num.intValue();
                                    if (intValue == 0) {
                                        x = x(2131689698);
                                    } else if (intValue == 1) {
                                        x = x(2131689683);
                                    } else if (intValue != 2) {
                                        x = x(2131690514);
                                    } else {
                                        x = x(2131689834);
                                    }
                                } else {
                                    x = x(2131690514);
                                }
                                if (outputSizes != null) {
                                    float[] fArr = (float[]) cameraCharacteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
                                    g gVar = new g(k());
                                    StringBuilder stringBuilder = new StringBuilder();
                                    stringBuilder.append(k.n(outputSizes));
                                    stringBuilder.append(" - ");
                                    stringBuilder.append(x);
                                    gVar.setMp(stringBuilder.toString());
                                    gVar.setResolution(k.o(outputSizes));
                                    StringBuilder stringBuilder2 = new StringBuilder();
                                    Object valueOf = (fArr == null || fArr.length == 0) ? "-" : Float.valueOf(fArr[0]);
                                    stringBuilder2.append(valueOf);
                                    stringBuilder2.append(" mm");
                                    gVar.setFlength(stringBuilder2.toString());
                                    gVar.setCameraId(str);
                                    this.X.addView(gVar);
                                }
                            }
                        } catch (Throwable unused) {
                        }
                    }
                } catch (Exception unused2) {
                }
            }
            a aVar = new a();
            this.Z = aVar;
            this.Y.setAdapter(aVar);
            this.X.setOnCheckedChangeListener(new h(this));
            if (this.X.getChildCount() != 0) {
                SingleSelectToggleGroup singleSelectToggleGroup = this.X;
                id = singleSelectToggleGroup.getChildAt(0).getId();
                i = singleSelectToggleGroup.q;
                if (id != i) {
                    if (i != -1) {
                        singleSelectToggleGroup.g(i, false);
                    }
                    View findViewById = singleSelectToggleGroup.findViewById(id);
                    if (findViewById instanceof Checkable) {
                        ((Checkable) findViewById).setChecked(true);
                    }
                    singleSelectToggleGroup.h(id, false);
                }
            }
        }
        i iVar = i.a;
        iVar = i.a;
        if (i.b.getBoolean("got_camera_note", false)) {
            viewGroup2 = this.W;
            viewGroup2.removeView(viewGroup2.findViewById(2131296764));
        } else {
            View findViewById2 = this.W.findViewById(2131296764);
            findViewById2.setOnClickListener(g.a);
            this.W.findViewById(2131296586).setOnClickListener(new i(this, findViewById2));
        }
        return this.W;
    }

    public String r0() {
        return DeviceInfoApp.c.getString(2131689672);
    }
}
